package org.phnq.babel.types;

import java.util.*;

public class JSNumber extends JSValue
{
	private int intVal;
	private double doubleVal;
	private boolean isInt;

	public JSNumber(int val)
	{
		super(VAL_TYPE_NUMBER);

		this.intVal = val;
		this.isInt = true;
	}

	public JSNumber(double val)
	{
		super(VAL_TYPE_NUMBER);

		this.doubleVal = val;
		this.isInt = false;
	}

	public boolean isInt()
	{
		return isInt;
	}

	public int intValue()
	{
		return isInt() ? intVal : (int)doubleVal;
	}

	public double doubleValue()
	{
		return isInt() ? (double)intVal : doubleVal;
	}
}
